import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// 引入 svgIcon 需要配置的插件
import {createSvgIconsPlugin} from 'vite-plugin-svg-icons'
import {viteMockServe} from 'vite-plugin-mock'

export default defineConfig(({command}) => {
  return {
    plugins: [
      vue(),
      createSvgIconsPlugin({
        iconDirs: [path.resolve(__dirname, 'src/assets/icons')],
        symbolId: 'icon-[dir]-[name]'
      }),
      viteMockServe({
        mockPath: './mock',
        enable: command === 'serve'
      })
    ],
    // 配置别名
    resolve: {
      alias: {
        '@': path.resolve(__dirname, './src')
      }
    },
    css: {
      preprocessorOptions: {
        scss: {
          javascriptEnabled: true,
            additionalData: '@import "./src/style/variables.scss"'
        }
      }
    }
  }
})
